<template>
  <div class="home-item">
    <div class="item-inner">
      <div class="cover">
        <img :src="itemData.image.url" alt="">
      </div>
      <div class="info">
        <div class="position">
          <img src="@/assets/img/home/home-location.svg" alt="">
          <div class="location">{{itemData.location}}</div>
        </div>
        <div class="name">{{itemData.houseName}}</div>
        <div class="summary">{{itemData.summaryText}}</div>
        <div class="price">
          <div class="new">￥{{itemData.finalPrice}}</div>
          <div class="old">￥{{itemData.productPrice}}</div>
          <van-tag
            class="diff" 
            type="danger"
            round 
            size="medium">￥{{itemData.productPrice - itemData.finalPrice}}</van-tag>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
defineProps({
  itemData:{
    type: Object,
    default: () => ({})
  }
})

</script>

<style lang='less' scoped>
.home-item{
  width: 50%;
  .item-inner{
    position: relative;
    margin: 5px;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    .cover{
      img{
        width: 100%;
        height: 130px;
      }
    }
  }
}
.info{
  top: 145px;
  width: 100%;
  .position{
    display: flex;
    img{
      width: 16px;
    }
  }
  .name{
    // 实现缩进两行...
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .price{
    display: flex;
    font-weight: 500;
    .new{
      color: var(--primary-color);
    }
    .old{
      font-size: 12px;
      text-decoration: line-through;
      color: var(--light-color)
    }
    .diff{
      padding: 0 10px;
      background-image: linear-gradient(90deg, #f7a0a8, red);
    }
  }
}
</style>